{include file="../include.tpl"}
<body>
{literal}
<script>
$(function() {
	setHeaderPos($("#divNavType").html().replace("Home",""));
		$( "input[type=submit],button" )
			.button()
			.click(function(event) {
			    var bid = $(event.target)[0].id;
				if(bid=="")
				{
					bid = $(event.target).parent()[0].id;
				}
			    $("#ui-id-1").html("创建子目录");
			    $("#name").val("");
			    if(bid=="backType")
				{
					window.history.go(-1);
				}
				else if(bid=="createUser")
			    {
					$("#dialog-form").dialog("open");
			    }
				else if(bid.indexOf("showChld")!=-1)
				{
					var id = bid.replace("showChld","");
					//alert(id);
					window.location = "?act=type&tid="+id;
				}
			    else if(bid.indexOf("editUser")!=-1)
			    {
			        //alert("mmmm");
			        var id = bid.replace("editUser","");
			        $("#editId").val(id);
			        $("#ui-id-1").html("编辑目录");
			        $("#name").val($("#tdName"+id).html());
					$("#name_en").val($("#tdName_en"+id).html());
					$("#name_jp").val($("#tdName_jp"+id).html());
			    	$("#dialog-form").dialog("open");
			    }
				else if(bid.indexOf("deleteU")!=-1)
			    {
					if(confirm("确认删除吗？"))
			        {
					var id = bid.replace("deleteU","");
					$.get("?act=type&op=ajaxDelWineType&id="+id,function(data)
			    		{
			    	    	var json = eval("("+data+")");
			    	    	if(json.st=="ok")
			    	    	{
			    	    	    alert(json.msg);
			    	    	    window.location=window.location;
			    	    	}
			    	    	else if(json.st=="err")
			    	    	{
			    	    	    alert(json.msg);
			    	    	}
			    	});
					}
				}
			    else if(bid.indexOf("btnDisable")!=-1)
			    {
			        if(confirm("确认停用吗？"))
			        {
						var id = bid.replace("btnDisable","");
			    		$.get("?act=game&op=ajaxGameDisable&id="+id,function(data)
			    		{
			    	    	var json = eval("("+data+")");
			    	    	if(json.st=="ok")
			    	    	{
			    	    	    alert(json.msg);
			    	    	    window.location=window.location;
			    	    	}
			    	    	else if(json.st=="err")
			    	    	{
			    	    	    alert(json.msg);
			    	    	}
			    		});
			        }
			    }
				else if(bid.indexOf("btnEnable")!=-1)
			    {
			        if(confirm("确认启用吗？"))
			        {
						var id = bid.replace("btnEnable","");
			    		$.get("?act=game&op=ajaxGameEnable&id="+id,function(data)
			    		{
			    	    	var json = eval("("+data+")");
			    	    	if(json.st=="ok")
			    	    	{
			    	    	    alert(json.msg);
			    	    	    window.location=window.location;
			    	    	}
			    	    	else if(json.st=="err")
			    	    	{
			    	    	    alert(json.msg);
			    	    	}
			    		});
			        }
			    }
		});
		$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 330,
			width: 450,
			modal: true,
			buttons: {
				"保存": function() {
					var bValid = true;
                    if($("#name").val()=="")
                    {
                       $("#td_msg_name").html("为必填项");
                       bValid = false;
                    }
                    //if($("#selMaker").val()=="0")
                    //{
                    //   $("#td_msg_maker").html("请选择");
                    //   bValid = false;
                    //}
                    //if($("#picMin").val()=="")
                    //{
                    //   $("#td_msg_picMin").html("请选择图片");
                    //   bValid = false;
                    //}
                   //if($("#picMax").val()=="")
                   // {
                   //    $("#td_msg_picMax").html("请选择图片");
                   //    bValid = false;
                   // }
					if(bValid ){

					    $("#formGame")[0].submit();
					}
				},
				"取消": function() {
					$(this).dialog( "close" );
				}
			},
			close: function() {
				
			}
		});
});
function doRank()
{
	var ids = $("#rankIds").val();
	$.post("?act=type&op=saveRank",{id:ids,tid:$("#tid").val()},function(data){
	     // alert(data);	
		  var json = eval("("+data+")");
		  alert(json.msg);
		  if(json.st=="ok")
		  {
			  window.location.href=window.location.href;
		  }
		  
	});
}
</script>
{/literal}
<iframe name="iframeSubmit" id="iframeSubmit" src="about:blank" style="display:none;"></iframe>
<div id="dialog-form" title="创建目录">
	<form name="formGame" id="formGame" method="post" action="?act={$act}&op=ajaxSaveType" enctype="multipart/form-data" target="iframeSubmit">
	<fieldset>
       <table height="120px" width="100%">
       <tr><td style="width:100px;">名称：</td><td style="width:180px;"><input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 
 
       </table>
	</fieldset>
	<input type="hidden" id="tid" name="tid" value="{$curTypeId}"/>
	<input type="hidden" id="editId" name="editId" value=""/>
	</form>
</div>
{include file='header.tpl'}
<table width="1000" style="margin:auto;" border="0" cellpadding="0" cellspacing="0">
   
  <tr>
   
    <td valign="top" ><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="4" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
 
          <tr>
            <td><table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="10%" height="35" valign="middle" style="text-align:right;">
                <div style="display:none" id="divNavType">素材目录&nbsp;&nbsp;&nbsp;{$curType}</div> <button id="createUser">创建目录</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="backType">返回上一目录</button></td>
              </tr>
            </table></td>
          </tr>
		  <tr>
            <td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
              <tr><td></td></tr></table>
            </td>
          </tr>
          <tr>
            <td>
            <div id="users-contain" class="ui-widget" style="width:100%;">
	<h1 style="display:none;">目录列表:<input type="text" size="100" id="rankIds" value="{$rankIds}"/><input type="button" onClick="doRank();" value="排序"/></h1>
	<table id="users" class="ui-widget ui-widget-content">
		<thead>
			<tr class="ui-widget-header ">
				<th style="width:30px;">编号</th>
				<th style="width:120px;">名称</th>
 
<th style="width:120px;">子类数量</th>
				<th style="width:120px;">创建时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
              {section name=sec1 loop=$data}
              <tr>
              <td>{$data[sec1].id}</td>
              <td id="tdName{$data[sec1].id}">{$data[sec1].name}</td>
 
<td id="tdCnum{$data[sec1].id}">{$data[sec1].cnum}</td>
              <td>{$data[sec1].addTime}</td>
              <td><button id="showChld{$data[sec1].id}">查看子目录</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="editUser{$data[sec1].id}">编辑</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="deleteU{$data[sec1].id}">删除</button></td>
              </tr>
              <input type="hidden" id="hidMakerId{$data[sec1].id}" value="{$data[sec1].makerId}"/>
              {/section}
		</tbody>
	</table>
</div>
 </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>
   
  </tr>
   <tr>
        <td  colspan="3" height="30" valign="middle">
     
    </td>
  </tr>
  <tr>
    <td   valign="middle">
     {include file='footer.tpl'} 
    </td>

  </tr>
</table>
</body>
